﻿using BackData;
using Domain;
using Infratructure;
using MediatR;
using Team.API.Applocation.Command.Quality;

namespace Team.API.Applocation.Hanldler.Quality
{
    public class GetWorkHandler : IRequestHandler<GetWorkCommand, APIResult<List<Workmodel>>>
    {
        private readonly IRepository<Workmodel> workRep;

        public GetWorkHandler(IRepository<Workmodel> workRep)
        {
            this.workRep = workRep;
        }
        public async Task<APIResult<List<Workmodel>>> Handle(GetWorkCommand request, CancellationToken cancellationToken)
        {
            var list = workRep.GetAll().Where(x => !x.IsDel);
            return new APIResult<List<Workmodel>>
            {
                Code = StateCode.OK,
                Result = list.ToList(),
                Message = "查询成功"
            };
        }
    }

}
